package com.shanghaiyimu.yimiyangche.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shanghaiyimu.yimiyangche.R;

import java.util.List;

/**
 * Created by Administrator on 2017/7/5.
 */

public class BiaoZhunPopAdapter extends BaseAdapter {

    private Context context;
    private List<String> list;

    public BiaoZhunPopAdapter(List<String> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list != null?list.size():0;
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.pop_item, viewGroup, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        }{
            holder = (ViewHolder) view.getTag();
        }
        holder.textView.setText(list.get(i));
        return view;
    }
    class ViewHolder{
        TextView textView;

        public ViewHolder(View view) {
            textView  = (TextView) view.findViewById(R.id.pop_item_text);
        }
    }
}
